<template>
  <div class="tip">
      <!--1.0从轮播图子组件中调用轮播图-->
        <swiper :imgs="list"></swiper> <!--这里的imgs来源于轮播图子组件中定义定名称-->
      <!--2.0 利用MUI的九宫格组件实现实现导航区域-->
        <div class="mui-content">
            <ul class="mui-table-view mui-grid-view mui-grid-9">
                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                    <router-link to="/news/newsIfo">
                        <span class="mui-icon mui-icon-home"></span>
                        <div class="mui-media-body">新闻资讯</div>
                    </router-link>
                </li>
                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                    <router-link to="/photo/photoList">
                        <span class="mui-icon mui-icon-email"></span>
                        <div class="mui-media-body">图片分享</div>
                    </router-link>
                </li>
                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                    <router-link to="/shop/shoplist">
                        <span class="mui-icon mui-icon-chatbubble"></span>
                        <div class="mui-media-body">商品购买</div>
                    </router-link>
                </li>
                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                    <router-link to="/feedback">
                        <span class="mui-icon mui-icon-location"></span>
                        <div class="mui-media-body">留言反馈</div>
                    </router-link>
                </li>
                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                    <router-link to="/video">
                        <span class="mui-icon mui-icon-search"></span>
                        <div class="mui-media-body">视频专区</div>
                    </router-link>
                </li>
                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                    <router-link to="/callme">
                        <span class="mui-icon mui-icon-phone"></span>
                        <div class="mui-media-body">联系我们</div>
                    </router-link>
                </li>
            </ul>
        </div>
  </div>
</template>

<script>
  import {Toast} from 'mint-ui'; //按要求导入mint-ui提示信息的文件,这是插件规定的写法
  import apiName from "../kits/common.js";//导入公共域名文件
  import swipe from "./subcom/swiper.vue"; //导入轮播图子组件
  export default {
    components: { //轮播图组件的注册
        swiper: swipe
    },
    data(){
        return {
            list: []
        }
    },
    created(){ //生命周期函数(自执行)。
      this.getImg();
    },
    methods:{
      getImg(){
        const url = apiName.domainName + '/api/getlunbo';//确定url地址，这里const是Es6中定义常量用的。
        this.$http.get(url).then(function(response){
            const data = response.body;
            //错误处理：
            if(data.status !== 0){//结束后续进程，并弹出错误信息。
              Toast("服务器错误");
              return;
            };
            this.list = data.message;
        });
      }
    }
  }
</script>

<style scoped>
    /*mui九宫格的样式设置*/
    .mui-grid-view.mui-grid-9 {
      background-color: #fff;
      border-top: 0;
      border-left: 0;
    }
    .mui-grid-view.mui-grid-9 .mui-table-view-cell {
      border-right: 0;
      border-bottom: 0;
    }
    .mui-grid-view.mui-grid-9 .mui-table-view-cell[data-v-6eced5dc] {
      padding: 0;
    }
    .mui-icon-home:before,
    .mui-icon-email:before,
    .mui-icon-chatbubble:before,
    .mui-icon-location:before,
    .mui-icon-search:before,
    .mui-icon-phone:before {
      content: '';
      width: 50px;
      height: 50px;
      display: inline-block;
    }
    .mui-icon-home:before {
      background: url("../../statics/imgs/1.png");
      background-size: cover;
      /*background-repeat: round;*/ /*两种都可以，注意，必须放在背景图下边*/
    }
    .mui-icon-email:before {
      background: url("../../statics/imgs/2.png");
      background-size: cover;
      /*background-repeat: round;*/ /*两种都可以，注意，必须放在背景图下边*/
    }
    .mui-icon-chatbubble:before {
      background: url("../../statics/imgs/3.png");
      background-size: cover;
      /*background-repeat: round;*/ /*两种都可以，注意，必须放在背景图下边*/
    }
    .mui-icon-location:before {
      background: url("../../statics/imgs/4.png");
      background-size: cover;
      /*background-repeat: round;*/ /*两种都可以，注意，必须放在背景图下边*/
    }
    .mui-icon-search:before {
      background: url("../../statics/imgs/5.png");
      background-size: cover;
      /*background-repeat: round;*/ /*两种都可以，注意，必须放在背景图下边*/
    }
    .mui-icon-phone:before {
      background: url("../../statics/imgs/6.png");
      background-size: cover;
      /*background-repeat: round;*/ /*两种都可以，注意，必须放在背景图下边*/
    }

    .mint-swipe[data-v-6eced5dc] {/*去除头部和轮播图模块间的空隙*/
      margin-top: -5px;
    }
    .mui-content > .mui-table-view:first-child {/*去除轮播图与九宫格顶部空隙*/
      margin-top: 0;
    }
</style>
